package com.webapi.common.utils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.webapi.core.model.persist.Agent;
import com.webapi.core.service.FacadeService;

public final class Parameters {
	private FacadeService service;

	public static final Parameters INSTANCE = new Parameters();
	private Map<String, Agent> agentMap = new HashMap<String, Agent>();
	
	private Parameters() {
	}
	
	public void init(FacadeService service) {
		this.service = service;
		initAgentMap();
	}
	
	private void initAgentMap() {
		List<Agent> agents = service.findAgents();
		for (Agent agent : agents) {
			agentMap.put(agent.getCode(), agent);
		}
	}
	
	/** ------------------------------------------------------- **/
	
	public Map<String, Agent> getAgentMap() {
		return agentMap;
	}

	public void setFacadeService(FacadeService facadeService) {
		this.service = facadeService;
	}
	
}
